#include "lf_base.h"

#if (__OS_LINUX__)
static LF_INLINE lf_atom_t lf_abstraction_cas( volatile lf_atom_t *destination, lf_atom_t exchange, lf_atom_t compare )
{
  lf_atom_t rv;

  assert( destination != NULL );
  // TRD : exchange can be any value in its range
  // TRD : compare can be any value in its range

  // TRD : note the different argument order for the GCC instrinsic to the MSVC instrinsic

  LF_BARRIER_COMPILER_FULL;

  rv = (lf_atom_t) __sync_val_compare_and_swap( destination, compare, exchange );

  LF_BARRIER_COMPILER_FULL;

  return( rv );
}
  
#endif

